<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Login One</title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
	<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
	<link href="css/templatemo_style.css" rel="stylesheet" type="text/css">	
</head>
<body class="templatemo-bg-gray">
	<div class="container">
		<div class="col-md-12">
			<h1 class="margin-bottom-15">登录至管理系统</h1>
			<div class="form-horizontal templatemo-container templatemo-login-form-1 margin-bottom-30" >				
		        <div class="form-group">
		          <div class="col-xs-12">		            
		            <div class="control-wrapper">
		            	<label for="username" class="control-label fa-label"><i class="fa fa-user fa-medium"></i></label>
		            	<input type="text" class="form-control" id="username" placeholder="用户名">
		            </div>		            	            
		          </div>              
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
		          	<div class="control-wrapper">
		            	<label for="password" class="control-label fa-label"><i class="fa fa-lock fa-medium"></i></label>
		            	<input type="password" class="form-control" id="password" placeholder="密码">
		            </div>
		          </div>
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
	             	<div class="checkbox control-wrapper">
	                	<label>
	                  		<input id="remember" type="checkbox"> 记住我
                		</label>
	              	</div>
		          </div>
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
		          	<div class="control-wrapper">
		          		<button id="sub" class="btn btn-info">登录</button>
		          	</div>
		          </div>
		        </div>
		      </div>
		</div>
	</div>
<script type="text/javascript" src="/hotel/js/jquery.min.js"></script>
<script type="text/javascript" src="/hotel/js/cookiesUtil.js"></script>
<script  type="text/javascript">
	//alert(getCookie('code'))
	if(getCookie('username')!=null){
		$('#username').val(getCookie('username'))
		$('#password').val(getCookie('password'))
		$('#remember').attr('checked',true)
	}
	
	$("#sub").click(function(){
		$.post("/hotel/system/login.do",
				{"username":$("#username").val(),"password":$("#password").val()},
				function(str){
					//alert(str)
					var res=eval('(' +str + ')')
					//alert(res.message);
					if(res.code==0){
						username=$('#username').val()
						password=$('#password').val()
						if($('#remember').is(':checked')){	//如果选中了记住我
							setCookie("username",username);
							setCookie("password",password)
							//alert(getCookie('password'))
						}else{
							deleteCookie("username");
							deleteCookie('password')
						}
						window.location.href="/hotel/system/mainPage"
					}else{
						alert(res.message);
					}
				});
		});
</script>
</body>
</html>